package com.aaa.inbound.mapper;

import com.aaa.entity.inbound.Purchase;
import com.aaa.entity.inbound.PurchaseDetail;
import com.aaa.entity.inbound.Receive;
import com.aaa.entity.inbound.ReceiveDetail;
import com.aaa.entity.inside.Allocation;
import com.aaa.entity.inside.AllocationDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author aaa
 * @since 2020-11-25
 */
public interface ReceiveMapper extends BaseMapper<Receive> {
    //根据采购单查询
    @Select("SELECT id,warehouseid,purchaseno,remark,state FROM i_purchase where purchaseno=#{no}")
    Purchase findPurchaseByNo(String no);

    //查询采购单详情
    @Select("SELECT commodityid,commoditybar,commodityname,qty FROM i_purchase_detail where pid=#{pid}")
    List<PurchaseDetail> findPurchaseDetailByPid(Long pid);

    //查询接货单
    @Select("SELECT id,warehouseid,state FROM i_receive where purchaseno=#{no}")
    Receive findReceiveByNo(String no);

    //查询接货单
    @Select("SELECT id,warehouseid,state FROM i_receive where allocationno=#{no}")
    Receive findReceiveALByNo(String no);

    //查询接货单详情
    @Select("SELECT id,commodityid,commoditybar,commodityname,qty FROM i_receive_detail WHERE pid=#{pid}")
    List<ReceiveDetail> findReceiveDetailByNo(Long pid);

    //查询调拨单
    @Select("SELECT id,warehouseid,state FROM allocation where allocationno=#{no}")
    Allocation findAllocationByNo(String no);

    //查询调拨单详情
    @Select("SELECT id,commodityid,commoditybar,commodityname,qty FROM s_allocation_detail WHERE pid=#{pid}")
    List<AllocationDetail> findAllocationDetailByPid(Long id);
}
